package cn.com.zzl.util;

import java.util.HashMap;
import java.util.Map;
import java.util.TreeMap;

/**
 * Description：测试类
 * Created by 朱正磊 on 2017-04-24 14:17.
 */
@SuppressWarnings("all")
public class Test {

	/**
	 * @Desc 测试for循环
	 * for循环合并是有条件的，不仅仅需要for条件相同，而且需要for内容互相不影响，
	 * 比如在两个for循环之间需要对for循环的内容执行一些操作，那么最好不要使用合并for循环。
	 * @param args
	 */
	/*public static void main(String[] args) {

		List<String> list = new ArrayList<String>();
		list.add("1");
		list.add("2");
		list.add("3");
		list.add("4");
		list.add("5");

		for(String string : list){
			System.out.println(string);
		}
		for(String string : list){
			System.out.println("【避免重复使用相同for循环】：" + string);
		}

		for(String string : list){
			System.out.println(string);
			System.out.println("【避免重复使用相同for循环】：" + string);
		}

	}*/

	/**
	 * @Desc 测试UUID
	 * @param args
	 */
	/*public static void main(String[] args) {

		//ef4720c03414438e8f4eeaaca5208186
		System.out.println(StringUtil.getUUID());

	}*/

	/**
	 * @Desc 测试File
	 * @param args
	 */
	/*public static void main(String[] args) throws IOException {
		//会正常打印但不会创建文件
		*//*File file = new File("E:\\test.txt");
		System.out.println(file.getName());//test.txt
		System.out.println(file.getAbsolutePath());//E:\test.txt*//*

		//如果文件不存在就创建
		*//*File file = new File("E:\\test.txt");
		if(!file.exists()){//如果文件不存在
			file.createNewFile();//创建文件
		}
		System.out.println(file.getName());//test.txt
		System.out.println(file.getAbsolutePath());//E:\test.txt*//*

		//会正常打印但不会创建文件
		*//*File file = new File("E:\\test\\test.txt");
		System.out.println(file.getName());//test.txt
		System.out.println(file.getAbsolutePath());//E:\test\test.txt*//*

		//如果文件不存在就创建
		File file = new File("E:\\test\\test.txt");
		//if(!file.exists()){//如果文件不存在
			//file.createNewFile();//Exception in thread "main" java.io.IOException: 系统找不到指定的路径。
		//}
		if(!file.getParentFile().exists()){//如果父文件（文件夹）不存在
			file.getParentFile().mkdirs();//只会创建文件夹，不会创建文件
		}
		if(!file.exists()){//如果文件不存在
			file.createNewFile();//创建文件
		}
		System.out.println(file.getName());//test.txt
		System.out.println(file.getAbsolutePath());//E:\test\test.txt

	}*/

	/**
	 * @Desc 测试indexOf()和contains()
	 * @param args
	 */
	/*public static void main(String[] args) {
		//indexOf
		String str1 = "1234.txt";
		System.out.println(str1.indexOf("."));//4
		String str2 = "1234txt";
		System.out.println(str2.indexOf("."));//-1

		//contains
		String str3 = "1234.txt";
		System.out.println(str3.contains("."));//true
		String str4 = "1234txt";
		System.out.println(str4.contains("."));//false
	}*/

	/**
	 * @Desc 测试Sheet，工作簿的工作表
	 * @param args
	 */
	/*public static void main(String[] args) {
		try {
			File file = new File("E:\\sheet\\myFirstExcel.xls");
			//File file = new File("E://sheet/myFirstExcel.xls");

			Workbook workbook = Workbook.getWorkbook(file);
			Sheet sheet = workbook.getSheet(0);

			Cell cell = sheet.getCell(0,0);//第1列第1行
			System.out.println(cell.getContents());//主键

			cell = sheet.getCell("B2");//第B列第2行
			System.out.println(cell.getContents());//特仑苏

			cell = sheet.getCell("C4");//第C列第4行
			System.out.println(cell.getContents());//650000

			cell = sheet.getCell("D2");//第D列第2行
			System.out.println(cell.getContents());//2017/4/25 03:11:38（2017-4-25  15:11:38）

			int rowLen = sheet.getRows();//工作表行数
			System.out.println(rowLen);//7

			int columnLen = sheet.getColumns();//工作表列数
			System.out.println(columnLen);//7

			Cell[] cellRowArray = sheet.getRow(0);
			System.out.println(cellRowArray.length);//7
			System.out.println(cellRowArray[1].getContents());//商品名称

			Cell[] cellColumnArray = sheet.getColumn(0);
			System.out.println(cellColumnArray.length);//7
			System.out.println(cellColumnArray[2].getContents());//16

			String sheetName = sheet.getName();
			System.out.println(sheetName);//sheetOne1

			boolean isHidden = sheet.isHidden();
			System.out.println(isHidden);//false
			boolean isProtected = sheet.isProtected();
			System.out.println(isProtected);//false

			cell = sheet.findCell("90");//Excel单元格内容格式可以是中文字符串，常规数字也行，但是日期格式不行
			System.out.println(cell.getRow());//匹配内容的第一个单元格所在的行号 4
			System.out.println(cell.getContents());//

			cell = sheet.findCell("7000",0,0,7,7,true);
			System.out.println(cell.getRow());//匹配内容的第一个单元格所在的行号 6
			System.out.println(cell.getContents());//7000

			cell = sheet.findCell(Pattern.compile("^[0-9]*$"),0,0,7,7,false);
			System.out.println(cell.getRow());//匹配内容的第一个单元格所在的行号 1
			System.out.println(cell.getContents());//15

			cell = sheet.findLabelCell("7000");//java.lang.NullPointerException，findLabelCell只查询字符串，不查询数字格式
			System.out.println(cell.getRow());
			System.out.println(cell.getContents());

		} catch (Exception e) {
			e.printStackTrace();
		}
	}*/

	/**
	 * @Desc 测试Sheet，工作簿的工作表，使用工具类SheetUtil
	 * @param args
	 */
	/*public static void main(String[] args) {
		try {
			//其中第一个参数代表Excel文件的全路径，
			//第二个参数代表工作簿从左到右第几个工作表，1就代表第一个
			SheetUtil sheetUtil = new SheetUtil("E:\\sheet\\myFirstExcel.xls",1);
			System.out.println(sheetUtil.getCellContents(2,2));//特仑苏(第2列第2行)
			System.out.println(sheetUtil.getCellContents("F4"));//我要买这么好的汽车(第F列第4行)
			System.out.println(sheetUtil.getRowLength());//工作表行数 7
			System.out.println(sheetUtil.getColumnLength());//工作表列数 7
			System.out.println(sheetUtil.getCellArrayOfRow(1).length);//第1行单元格数组的长度 7
			System.out.println(sheetUtil.getCellArrayOfRow(1)[1].getContents());//商品名称
			System.out.println(sheetUtil.getCellArrayOfColumn(2).length);//第2列单元格数组的长度 7
			System.out.println(sheetUtil.getCellArrayOfColumn(2)[2].getContents());//捷安特
			System.out.println(sheetUtil.getSheetName());//sheetOne1
			System.out.println(sheetUtil.isHidden());//false
			System.out.println(sheetUtil.isProtected());//false
			System.out.println(sheetUtil.findCellByContents("90").getContents());//内容90
			System.out.println(sheetUtil.findRowNumOfCellByContents("90"));//第5行
			System.out.println(sheetUtil.findLabelCellByContents("15").getContents());//内容15，必须是字符串，不能是数字
			System.out.println(sheetUtil.findRowNumOfLabelCellByContents("15"));//第2行
			System.out.println(sheetUtil.findCellByCondition("7000",1,1,7,7,true).getContents());//内容7000
			System.out.println(sheetUtil.findRowNumOfCellByCondition("7000",1,1,7,7,true));//第7行
			System.out.println(sheetUtil.findCellByCondition(Pattern.compile("^[0-9]*$"),1,1,7,7,false).getContents());//内容15
			System.out.println(sheetUtil.findRowNumOfCellByCondition(Pattern.compile("^[0-9]*$"),1,1,7,7,false));//第2行
		} catch (Exception e) {
			e.printStackTrace();
		}
	}*/

	/**
	 * @Desc 测试 if else 简写
	 * @param args
	 */
	/*public static void main(String[] args) {

		//1 只有if，没有else
		int a = 1 ;
		int b = 2 ;
		if(a > b)
		a = 2;//if对这行有效
		b = 3;//if对这行无效
		System.out.println(a);//1
		System.out.println(b);//3

		//2 既有if，也有else
		int i = 1 ;
		int j = 2 ;
		if(i < j)
		i = 2;
		//j = 3;
		else
		i = 3;
		j = 3;
		System.out.println(i);//2
		System.out.println(j);//3
	}*/

	/**
	 * @Desc 测试DecimalFormat
	 * @param args
	 */
	/*public static void main(String[] args) {
		DecimalFormat df1 = new DecimalFormat("0.0");
		DecimalFormat df2 = new DecimalFormat("#.#");
		DecimalFormat df3 = new DecimalFormat("000.000");
		DecimalFormat df4 = new DecimalFormat("###.###");
		DecimalFormat df5 = new DecimalFormat("0");
		DecimalFormat df6 = new DecimalFormat("#");
		System.out.println(df1.format(12.34));//12.3
		System.out.println(df2.format(12.34));//12.3
		System.out.println(df3.format(12.34));//012.340
		System.out.println(df3.format(12.344567));//012.345，四舍五入
		System.out.println(df4.format(12.34));//12.34
		System.out.println(df5.format(1234.1234));//1234
		System.out.println(df6.format(1234.1234));//1234
	}*/

	/**
	 * 测试null
	 * @param args
	 */
	/*public static void main(String[] args) {
		Integer integer = null;
		String str = integer.toString();
		System.out.println(str);//Exception in thread "main" java.lang.NullPointerException
	}*/

	/**
	 * 测试List<Object>
	 * @param args
	 */
	/*public static void main(String[] args) {
		List<Integer> list = new ArrayList<Integer>();
		//List<Object> list1 = new ArrayList<Integer>();//不可行
		Object list2 = new ArrayList<Integer>();
		Object list3 = new Integer(1);
	}*/

	/**
	 * 测试栈溢出StackOverFlow
	 * @param args
	 */
	/*public static void main(String[] args) {
		xx("xx");//递归到死，无限循环
	}

	public static int xx(String xx){
		return xx(xx);
	}*/

	/**
	 * 测试控制台输出信息
	 * 仅输出至文件output.txt
	 * @param args
	 */
	/*public static void main(String[] args) throws IOException {
		try {
			OutputStream out = new FileOutputStream(new File("E:\\my_log\\output.txt"));
			System.setOut(new PrintStream(out));//仅仅只记录System.out打印的内容
			System.out.println("11 output to output.txt");
			System.out.println("22 output to output.txt");
			System.out.println("33 output to output.txt");
			System.out.println("44 output to output.txt");
			System.out.println("55 output to output.txt");
			System.out.println("66 output to output.txt");
		} catch (IOException e) {
			e.printStackTrace();
			FileUtil.printExceptionInfo(e);
		}

	}*/

	/**
	 * @Desc 在控制台与文件间进行切换
	 * @param args
	 */
	/*public static void main(String[] args) throws IOException {
		try {
			PrintStream out = System.out;

			OutputStream outputStream = new FileOutputStream(new File("E:\\my_log\\output.txt"));

			System.setOut(new PrintStream(outputStream));//仅仅只记录System.out打印的内容
			System.out.println("1 output to output.txt");

			System.setOut(out);
			System.out.println("1 output to output.txt over");

			System.setOut(new PrintStream(outputStream));//仅仅只记录System.out打印的内容
			System.out.println("2 output to output.txt");

			System.setOut(out);
			System.out.println("2 output to output.txt over");
		} catch (FileNotFoundException e) {
			e.printStackTrace();
			FileUtil.printExceptionInfo(e);
		}
	}*/

	/**
	 * @Desc 测试System类
	 * @param args
	 */
	/*public static void main(String[] args) {
		System.out.println(System.getProperty("user.dir"));// 打印结果 D:\workspace\project\ideaProject\demo
		System.out.println(System.getProperty("file.separator"));// 打印结果 \
		System.out.println(System.currentTimeMillis());//获取当前系统时间
		System.out.println(new Date(System.currentTimeMillis()));//Date(long date)
		System.out.println(new Date());//new Date(System.currentTimeMillis())等同于new Date()
		System.out.println("I love you , baby!");
		//System.exit(1);//参数为0表示正常停止Java虚拟机运行，参数非0表示非正常停止Java虚拟机运行
		System.out.println("I love you , cute baby!");

		int[] arr1 = {11,22,33,44,55};
		int[] arr2 = {5,6,7,8,9,10};
		//public static void arraycopy(Object src,int srcPos,Object dest,int destPos,int length)
		System.arraycopy(arr1,1,arr2,2,2);
		System.out.println(Arrays.toString(arr1));//[11, 22, 33, 44, 55]
		System.out.println(Arrays.toString(arr2));//[5, 6, 22, 33, 9, 10]
	}*/

	/**
	 * @Desc 测试StringBuilder类
	 * @param args
	 */
	/*public static void main(String[] args) {
		StringBuilder builder = new StringBuilder("abcdefg");//abcdefg
		builder.append("1234567");//abcdefg1234567
		System.out.println(builder);
		builder.replace(2,2,"mm");//abmmcdefg1234567
		System.out.println(builder);
		builder.replace(0,2,"xx");//包含开始不包含结尾xxmmcdefg1234567
		System.out.println(builder);
		builder.insert(5,"uuu");//xxmmcuuudefg1234567
		System.out.println(builder);
		builder.delete(3,4);//包含开始不包含结尾xxmcuuudefg1234567
		System.out.println(builder);
		System.out.println(builder.length());//18
		//因为SringBuilder重写了toString()这个方法，返回StringBuilder对象的字符串内容
		//输出builder即输出builder.toString()，即字符串内容
		//但是如果我们想使用字符串形式，必须通过toString()进行类型转换
		System.out.println(builder.toString());//xxmcuuudefg1234567
		System.out.println(builder.indexOf("uuu"));//4
		System.out.println(builder.indexOf("u"));//4
		System.out.println(builder.indexOf("x"));//0
		System.out.println(builder.substring(0));//xxmcuuudefg1234567还是原字符串
		System.out.println(builder.substring(10));//g1234567，从索引10开始直到结束
		System.out.println(builder.substring(10,15));//g1234，从索引10开始，不包括15
		System.out.println(builder.charAt(9));//f
		//builder.deleteCharAt(9);//xxmcuuudeg1234567
		System.out.println(builder.deleteCharAt(9));//xxmcuuudeg1234567
		System.out.println(builder);//xxmcuuudeg1234567
	}*/

	/**
	 * @Desc 测试Math类
	 * @param args
	 */
	/*public static void main(String[] args) {
		//abs取绝对值
		System.out.println(Math.abs(-9.87));//9.87
		System.out.println(Math.abs(0.987));//0.987

		//ceil 取大（.0）
		System.out.println(Math.ceil(-10.1));//-10.0
		System.out.println(Math.ceil(10.74));//11.0
		System.out.println(Math.ceil(-0.78));//-0.0
		System.out.println(Math.ceil(0.0));//0.0
		System.out.println(Math.ceil(-0.0));//-0.0

		//floor 取小（.0）
		System.out.println(Math.floor(-10.1));//-11.0
		System.out.println(Math.floor(10.74));//10.0
		System.out.println(Math.floor(-0.78));//-1.0
		System.out.println(Math.floor(0.0));//0.0
		System.out.println(Math.floor(-0.0));//-0.0

		//max 取两者之间的较大值
		System.out.println(Math.max(10,12));//12
		System.out.println(Math.max(-10,-12));//-10
		System.out.println(Math.max(0,-0));//0
		System.out.println(Math.max(10.99,-12.88));//10.99

		//min 取两者之间的较小者
		System.out.println(Math.min(10,12));//10
		System.out.println(Math.min(-10,-12));//-12
		System.out.println(Math.min(0,-0));//0
		System.out.println(Math.min(10.99,-12.88));//-12.88

		//rint 四舍五入，返回double值
		//注意.5的时候会取偶数
		System.out.println(Math.rint(10.1));//10.0
		System.out.println(Math.rint(10.7));//11.0
		System.out.println(Math.rint(11.5));//12.0
		System.out.println(Math.rint(10.5));//10.0
		System.out.println(Math.rint(10.51));//11.0
		System.out.println(Math.rint(-10.5));//-10.0
		System.out.println(Math.rint(-11.5));//-12.0
		System.out.println(Math.rint(-10.51));//-11.0
		System.out.println(Math.rint(-10.6));//-11.0
		System.out.println(Math.rint(-10.2));//-10.0

		//round 四舍五入，float时返回int值，double时返回long值
		//System.out.println(Math.round());
		System.out.println(Math.round(10.1));//10
		System.out.println(Math.round(10.7));//11
		System.out.println(Math.round(11.5));//12
		System.out.println(Math.round(10.5));//11
		System.out.println(Math.round(10.51));//11
		System.out.println(Math.round(-10.5));//-10
		System.out.println(Math.round(-11.5));//-11
		System.out.println(Math.round(-10.51));//-11
		System.out.println(Math.round(-10.6));//-11
		System.out.println(Math.round(-10.2));//-10

	}*/

	/**
	 * @Desc 测试Thread类
	 * @param args
	 */
	/*public static void main(String[] args) {
		Thread thread1 = new Thread();
		Thread thread2 = new Thread("thread2");
		thread1.start();//启动线程
		thread2.start();//启动线程

		Runnable run = new Runnable() {
			@Override
			public void run() {
				System.out.println("runnable is running");
			}
		};
		//Runnable run = () -> System.out.println("runnable is running");
		Thread thread3 = new Thread(run);
		Thread thread4 = new Thread(run,"thread4");
		thread3.start();//启动线程
		thread4.start();//启动线程

		System.out.println("===================================================================");

		//设置优先级别
		thread1.setPriority(Thread.MIN_PRIORITY);//1，public final static int MIN_PRIORITY = 1;
		thread3.setPriority(Thread.NORM_PRIORITY);//5，public final static int NORM_PRIORITY = 5;
		thread4.setPriority(Thread.MAX_PRIORITY);//10，public final static int MAX_PRIORITY = 10;
		System.out.println(thread1.getPriority());//1
		System.out.println(thread2.getPriority());//5（默认Thread.NORM_PRIORITY）
		System.out.println(thread3.getPriority());//5
		System.out.println(thread4.getPriority());//10

		System.out.println("===================================================================");

		*//*try {
			Thread.sleep(1000);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}*//*

		//判断线程是否活动
		System.out.println(thread1.isAlive());//true
		System.out.println(thread2.isAlive());//true
		System.out.println(thread3.isAlive());//true
		System.out.println(thread4.isAlive());//true

		System.out.println("===================================================================");

		//判断是否守护线程
		System.out.println(thread1.isDaemon());//false
		System.out.println(thread2.isDaemon());//false
		System.out.println(thread3.isDaemon());//false
		System.out.println(thread4.isDaemon());//false

		System.out.println("===================================================================");

		//获得线程状态
		System.out.println(thread1.getState());//RUNNABLE
		System.out.println(thread2.getState());//RUNNABLE
		System.out.println(thread3.getState());//RUNNABLE
		System.out.println(thread4.getState());//RUNNABLE

		System.out.println("===================================================================");

		try {
			thread1.join();//等待线程结束
		} catch (InterruptedException e) {
			e.printStackTrace();
		}

	}*/

	/**
	 * @Desc java.lang.ClassCastException 类型转换异常
 	 * @param args
	 */
	/*public static void main(String[] args) {
		Map<String,Object> map = new HashMap<String,Object>();
		map.put("realityPay","");
		//Exception in thread "main" java.lang.ClassCastException: java.lang.String cannot be cast to java.math.BigDecimal
		BigDecimal bigDecimal = (BigDecimal) map.get("realityPay");
		System.out.println(bigDecimal);
	}*/

	/**
	 * @Desc 比较 do while 和 while
	 * @param args
	 */
	/*public static void main(String[] args) {
		boolean flag ;
		do{
			System.out.println("你好，周杰伦！");
			flag = false;
		}
		while(flag);

		while(!flag){
			System.out.println("你好，王力宏！");
			flag = true;
		}
	}*/

	/**
	 * @Desc 测试LogTool
	 * @param args
	 */
	/*public static void main(String[] args) throws IOException {
		LogTool logTool = new LogTool("myLog");
		logTool.log("测试日志文件正常",null);
		try {
			new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse("1990-12-26");
		} catch (Exception e) {
			logTool.log("测试日志文件异常",e);
		}

		//建议使用上面的生成日志的方式

		try {
			new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse("1990-12-26");
		} catch (ParseException e) {
			e.printStackTrace();
			//saveContent(e.getMessage());//稍微简略 Unparseable date: "1990-12-26"
			//saveContent(e.toString());//稍微详细 java.text.ParseException: Unparseable date: "1990-12-26"
			FileUtil.printExceptionInfo(e);
		}
	}*/

	/**
	 * @Desc 测试Class
	 * @param args
	 */
	/*public static void main(String[] args) throws Exception {

		//1、第一步： JVM使用类装载器将类装入内存（前提是类还没有被装入内存），但是不进行类的初始化操作
		Class TestClass1 = TestClass.class;
		System.out.println("TestClass1：" + TestClass1);//TestClass1：class cn.itcast.ssm.util.TestClass

		//2、第二步：JVM加载类，进行类的静态初始化操作
		Class TestClass2 = Class.forName("cn.itcast.ssm.util.TestClass");//参数为类的全路径，即包名+类名
		System.out.println("TestClass2：" + TestClass2);//TestClass2：class cn.itcast.ssm.util.TestClass

		//3、第三步：实例化类的对象进行非静态初始化操作以及构造函数
		TestClass TestClass = new TestClass();
		Class TestClass3 = TestClass.getClass();
		System.out.println("TestClass3：" + TestClass3);//TestClass3：class cn.itcast.ssm.util.TestClass

	}*/

	/**
	 * @Desc 测试拼音工具类
	 * @param args
	 */
	/*public static void main(String[] args) {

		//将字符串中的中文转化为拼音，其他字符不变  不去掉字符串内部空格（两边的空格去掉）
		System.out.println(PinYinUtil.getPinYin("  朱正磊 love 翟甜 1万年  *  "));//zhuzhenglei love zhaitian 1wannian  *

		//将中文字符转换为拼音首字母小写，其他不变  去掉'[^A-Za-z0-9_]'（比如空格、*、%、#、@、&等等）
		System.out.println(PinYinUtil.getFirstSpell("   朱正磊 love 翟甜 1万年   *   "));//zzllovezt1wn

		//将字符串中的中文转化为拼音，其他字符不变
		System.out.println(PinYinUtil.getFullSpell("   朱正磊 love 翟甜 1万年   *   "));//   zhuzhenglei love zhaitian 1wannian   *

	}*/

	/**
	 * @Desc  Java获取当前类名、方法名
	 * @param args
	 */
	/*public static void main(String[] args) {

		//获取当前类名

		// 方法1：通过SecurityManager的保护方法getClassContext()
		String clazzName = new SecurityManager(){
			public String getClassName(){//getClassName可以自定义
				return getClassContext()[1].getName();
			}
		}.getClassName();
		System.out.println(clazzName);//cn.itcast.ssm.util.Test

		// 方法2：通过Throwable的方法getStackTrace()
		String clazzName2 = new Throwable().getStackTrace()[0].getClassName();
		System.out.println(clazzName2);//cn.itcast.ssm.util.Test

		// 方法3：通过分析匿名类名称()
		String clazzName3 = new Object(){
			public String getClassName(){//getClassName可以自定义
				String clazzName = this.getClass().getName();
				//'$'（int）和"$"（String）效果一样
				return clazzName.substring(0,clazzName.lastIndexOf("$"));
			}
		}.getClassName();
		System.out.println(clazzName3);//cn.itcast.ssm.util.Test

		//方法4：通过Thread的方法getStackTrace()
		String clazzName4 = Thread.currentThread().getStackTrace()[1].getClassName();
		System.out.println(clazzName4);//cn.itcast.ssm.util.Test

		//方法5：通过Exception的方法getStackTrace()（与Throwable类似）
		String clazzName5 = new Exception().getStackTrace()[0].getClassName();
		System.out.println(clazzName5);//cn.itcast.ssm.util.Test

		//获取当前方法名

		// 方法1：通过Throwable的方法getStackTrace()
		String funcName1 = new Throwable().getStackTrace()[0].getMethodName();
		System.out.println(funcName1);//main

		//方法2：通过Thread的方法getStackTrace()
		String funcName2 = Thread.currentThread().getStackTrace()[1].getMethodName();
		System.out.println(funcName2);//main

		// 方法3：通过Exception的方法getStackTrace()（与Throwable类似）
		String funcName3 = new Exception().getStackTrace()[0].getMethodName();
		System.out.println(funcName3);//main

		//获取调用者方法名
		String funcName33 = new Exception().getStackTrace()[1].getMethodName();
		System.out.println(funcName33);//invoke0

		String funcName44 = new Throwable().getStackTrace()[1].getMethodName();
		System.out.println(funcName44);//invoke0

	}*/

	/**
	 * @Desc  Java获取当前类名、方法名，使用工具类ClassUtil
	 * @param args
	 */
	/*public static void main(String[] args) {

		//获取当前类名 cn.itcast.ssm.util.ClassUtil
		System.out.println(ClassUtil.getCurrentClassName());
		//获取当前方法名 getCurrentMethodName
		System.out.println(ClassUtil.getCurrentMethodName());
		//获取当前类名、方法名、行号
		//class: cn.itcast.ssm.util.ClassUtil; method: getCurrentInfo; lineNumber: 31
		System.out.println(ClassUtil.getCurrentInfo());

		//获取调用者类名 cn.itcast.ssm.util.Test
		System.out.println(ClassUtil.getInvokingClassName());
		//获取调用者方法名 main
		System.out.println(ClassUtil.getInvokingMethodName());
		//获取调用者类名、方法名、行号
		//class: cn.itcast.ssm.util.Test; method: main; lineNumber: 713
		System.out.println(ClassUtil.getInvokingInfo());

	}*/

	/**
	 * @Desc 测试String为null
	 * @param args
	 */
	/*public static void main(String[] args) {
		String xx = null;
		System.out.println(xx);//null
	}*/

	/**
	 * @Desc 局部变量初始化
	 * @param args
	 */
	/*public static void main(String[] args) {
		String d;//局部变量
		//System.out.println(d);//局部变量未被初始化jvm编译不通过
	}*/

	/**
	 * @Desc 测试JSONObject
	 */
	/*public static void main(String[] args) {
		//Integer integer = new Integer(123);
		//String string = new String("bbb");
		User user1 = new User();
		user1.setUsername("zzl");
		user1.setSex("男");
		//System.out.println(object2JsonObject(integer));//不适用
		//System.out.println(object2JsonObject(string));//不适用
		System.out.println(JSONUtil.object2JsonObject(user1));//{"address":"","birthday":null,"id":0,"sex":"男","username":"zzl"}
		//System.out.println(object2JsonObjectString(integer));//不适用
		//System.out.println(object2JsonObjectString(string));//不适用
		System.out.println(JSONUtil.object2JsonObjectString(user1));//{"address":"","birthday":null,"id":0,"sex":"男","username":"zzl"}
	}*/

	/**
	 * @Desc  获取javaBean中的所有属性
	 * @param args
	 */
	/*public static void main(String[] args) {
		PropertyDescriptor[] propertyDescriptors ;
		try {
			//方法一：
			//propertyDescriptors = Introspector.getBeanInfo(User.class).getPropertyDescriptors();
			//方法二：
			User user = new User();
			propertyDescriptors = Introspector.getBeanInfo(user.getClass()).getPropertyDescriptors();
			if(propertyDescriptors != null){
				for(int i = 0; i < propertyDescriptors.length; i++){
					String name = propertyDescriptors[i].getName();//获取javaBean的属性名称
					Object type = propertyDescriptors[i].getPropertyType();//获取javaBean的属性类型
					System.out.println(name + "：" + type);
					//打印内容如下：
					*//*
						address：class java.lang.String
						birthday：class java.util.Date
						class：class java.lang.Class
						id：class java.lang.Integer
						sex：class java.lang.String
						username：class java.lang.String
					*//*
					//发现：出了我们自定义的属性之外，还有一个默认的属性class
				}
			}
		} catch (IntrospectionException e) {
			e.printStackTrace();
		}
	}*/

	/**
	 *
	 * @param args
	 */
	/*public static void main(String[] args) {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("name","zzl");
		int age1 = 123;
		map.put("age",age1);
		boolean flag1 = true;
		map.put("flag",flag1);
		Object name = map.get("name");
		Object age = map.get("age");
		Object flag = map.get("flag");
		System.out.println("name=" + name + ",age=" + age + ",flag=" + flag);
	}*/

	/**
	 * @Desc 测试JSONTool
	 * @param args
	 */
	/*public static void main(String[] args) throws Exception {
		People people = new People();
		people.setId("01");
		people.setName("张三");
		people.setAge(33);
		people.setPay(6666.88);
		people.setValid(true);
		people.setOne('E');
		people.setBirthday(new Date());

		Link link = new Link();
		link.setAddress("河南省济源市");
		link.setPhone("13899995555");
		link.setQq("123456");
		people.setLink(link);

		Map map = new HashMap();
		map.put("aa", "this is aa");
		map.put("bb", "this is bb");
		map.put("cc", "this is cc");
		people.setMap(map);

		List list = new ArrayList();
		list.add("普洱");
		list.add("大红袍");
		people.setList(list);

		Set set = new HashSet();
		set.add("篮球");
		set.add("足球");
		set.add("乒乓球");
		people.setSet(set);

		//1、javaBean 转 json字符串
		String jsonString = JSONTool.javaBean2JsonString(people);
		System.out.println(jsonString);
		// {"id":"01","name":"张三","age":33,
		// "pay":6666.88,
		// "valid":true,"one":"E",
		// "birthday":1496215793649,
		// "link":{"phone":"13899995555","address":"河南省济源市","qq":"123456"},
		// "map":{"aa":"this is aa","bb":"this is bb","cc":"this is cc"},
		// "list":["普洱","大红袍"],
		// "set":["足球","篮球","乒乓球"]}


		//2、json字符串 转 javaBean
		people = JSONTool.jsonString2JavaBean(jsonString, People.class);
		System.out.println("pay：" + people.getPay());
		System.out.println("valid：" + people.isValid());
		System.out.println("birthday：" + people.getBirthday());
		System.out.println("link：" + people.getLink());
		System.out.println("map：" + people.getMap());
		System.out.println("list：" + people.getList());
		System.out.println("set：" + people.getSet());
		//pay：6666.88
		//valid：true
		//birthday：Wed May 31 15:33:39 CST 2017
		//link：cn.itcast.ssm.po.Link@26be92ad
		//map：{aa=this is aa, bb=this is bb, cc=this is cc}
		//list：[普洱, 大红袍]
		//set：[足球, 篮球, 乒乓球]


		//3、json字符串 转 Map
		Map mapValue = JSONTool.jsonString2Map(jsonString);
		System.out.println(mapValue);
		// {id=01, name=张三, age=33, pay=6666.88,
		// valid=true, one=E,
		// birthday=1496216168551,
		// link={phone=13899995555, address=河南省济源市, qq=123456},
		// map={aa=this is aa, bb=this is bb, cc=this is cc},
		// list=[普洱, 大红袍],
		// set=[足球, 篮球, 乒乓球]}


		//4、Map 转 json字符串
		jsonString = JSONTool.map2jsonString(mapValue);
		System.out.println(jsonString);
		// {"id":"01","name":"张三","age":33,
		// "pay":6666.88,
		// "valid":true,"one":"E",
		// "birthday":1496215793649,
		// "link":{"phone":"13899995555","address":"河南省济源市","qq":"123456"},
		// "map":{"aa":"this is aa","bb":"this is bb","cc":"this is cc"},
		// "list":["普洱","大红袍"],
		// "set":["足球","篮球","乒乓球"]}

	}*/

	/**
	 * @Desc 测试ArrayUtil
	 * @param args
	 */
	/*public static void main(String[] args) {

		Integer[] integers = new Integer[]{1,2,3};

		//数组转换为List
		List<Integer> integerList = ArrayUtil.array2List(integers);
		System.out.println(integerList);//[1, 2, 3]

		//List转换为数组
		Integer[] ints = ArrayUtil.list2Array(integerList);
		System.out.println(ArrayUtil.array2String(ints));//[1, 2, 3]
		System.out.println(ints.length);//3
		System.out.println(ints[0]);//1
		System.out.println(ints[1]);//2
		System.out.println(ints[2]);//3

		//JSONTool.mapper，因为字段mapper是由private修饰的，只能在JSONTool类里面使用！

	}*/

	/**
	 * @Desc 测试基本数据类型 byte 和 char
	 * @param args
	 */
	/*public static void main(String[] args) {

		String str = "abc";
		char a = str.charAt(0);
		System.out.println(a);//a

		char c = 'c';
		System.out.println(c);//c

		char ch = 100;
		System.out.println(ch);//d，因为ASCII码表中的100代表的是字符c



		byte b = 98;
		System.out.println(b);//98

		byte bt = 'e';
		System.out.println(bt);//101

		String s = "s";
		byte[] bytes = s.getBytes();
		System.out.println(bytes.length);//1
		System.out.println(bytes[0]);//115，115是s字符对应的ASCII码的值（10进制）
		//System.out.println(bytes[1]);//java.lang.ArrayIndexOutOfBoundsException: 1



		/*//***************【1】*****************//*/
		//char是无符号型的，可以表示一个整数，不能表示负数；而byte是有符号型的，可以表示-128—127的数
		char c1 = (char) -9;//char不能识别负数，必须强制转换否则报错，即使强制转换之后，也无法识别
		//System.out.println(c1);//
		byte b1 = -1;
		byte b2 = 1;
		byte b3 = -128;//如果byte b3 = -129;会报错
		byte b4 = 127;//如果byte b4 = 128;会报错
		System.out.println(b1);//-1
		System.out.println(b2);//1
		System.out.println(b3);//-128
		System.out.println(b4);//127


		/*//***************【2】*****************//*/
		//char可以表中文字符，byte不可以
		char c2 = '中';
		char c3 = '国';
		byte b5 = (byte) c2;//必须强制转换否则报错
		System.out.println(c2);//中
		System.out.println(c3);//国
		System.out.println(b5);//45


		/*//***************【3】*****************//*/
		//char、byte、int对于英文字符，可以相互转化
		byte g = 'b';//字符b对应的ASCII码是98
		char h = (char) g;//h其实就是字符b
		char i = 85;//字符U对应的ASCII码是85
		int j = 'h';//字符h对应ASCII码是104
		System.out.println(g);//98
		System.out.println(h);//b
		System.out.println(i);//U
		System.out.println(j);//104

	}*/

	/**
	 * 说明：args是一个字符串数组的变量名，不是关键字，是arguments的缩写，只是一个默认名，一般都习惯性照写
	 * @Desc
	 * @param args
	 */
	/*public static void main(String[] args){

	}*/

	/**
	 * @Desc 测试异常信息1
	 * @param args
	 */
	/*public static void main(String[] args) {
		try {
			int i = 0;
			int result = 10 / i;
		} catch (Exception e) {
			//e.printStackTrace();

			//java.lang.ArithmeticException: / by zero
			//at cn.itcast.ssm.util.Test.main(Test.java:1015)
			//at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
			//at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
			//at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
			//at java.lang.reflect.Method.invoke(Method.java:483)
			//at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)

			//System.out.println(e.getStackTrace());//[Ljava.lang.StackTraceElement;@6f496d9f
			//System.out.println(e.getMessage());/// by zero
			//System.out.println(e.getCause());//null

			//System.err.println(e);//java.lang.ArithmeticException: / by zero

			System.out.println(ExceptionUtil.getStackTrace(e));

			System.out.println(ExceptionUtil.logExceptionStack(e));
		}

	}*/

	/**
	 * @Desc 测试异常信息2
	 * @param args
	 */
	/*public static void main(String[] args) {
		try {
			String s = null;
			s.equals("");
		} catch (Exception e) {
			//e.printStackTrace();

			//java.lang.NullPointerException
			//at cn.itcast.ssm.util.Test.main(Test.java:1041)
			//at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
			//at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
			//at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
			//at java.lang.reflect.Method.invoke(Method.java:483)
			//at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)

			//System.out.println(e.getStackTrace());//[Ljava.lang.StackTraceElement;@6f496d9f
			//System.out.println(e.getMessage());/// null
			//System.out.println(e.getCause());//null

			System.out.println(e);//java.lang.NullPointerException


		}

	}*/

	/**
	 * @Desc 测试ArrayList和数组的区别
	 * @param args
	 */
	/*public static void main(String[] args) {
		String[] array1 = new String[]{"123","sdc","de2","der4"};

		String[] array2 = new String[4];
		array2[0] = "123";
		array2[1] = "sdc";
		array2[2] = "de2";
		array2[3] = "der4";

		System.out.println(array1.length);
		System.out.println(array1[0]);
		System.out.println(array2.length);
		System.out.println(array2[1]);

		List<String> stringList = new ArrayList<String>();
		stringList.add("123");
		stringList.add("sdc");
		stringList.add("de2");
		stringList.add("der4");
		System.out.println(stringList.size());
		System.out.println(stringList.get(0));
		System.out.println(stringList.get(1));
		System.out.println(stringList.get(2));
		System.out.println(stringList.get(3));
	}*/

	/**
	 * @Desc 测试List集合的实例化形式
	 * @param args
	 */
	/*public static void main(String[] args) {
		//1、
		List<User> userList = new ArrayList<User>();
		User user = new User();
		user.setUsername("朱正磊1");
		userList.add(user);
		System.out.println(userList.get(0).getUsername());
		//2、这种写法在idea里面也是可以的，但是jdk的版本要在1.7及以上，这是属于Java SE 7新特性
		List<Items> itemsList = new ArrayList<>();
		//3、
		List<Items> itemsList1 = new ArrayList();
		Items items1 = new Items();
		items1.setName("朱正磊2");
		itemsList1.add(items1);
		System.out.println(itemsList1.get(0).getName());
		//4、
		List itemsList2 = new ArrayList<Items>();
		Items items2 = new Items();
		items2.setName("朱正磊3");
		itemsList2.add(items2);
		System.out.println(((Items)itemsList2.get(0)).getName());
		//5、这种写法在idea里面也是可以的，但是jdk的版本要在1.7及以上，这是属于Java SE 7新特性
		List itemsList3 = new ArrayList<>();
		//6、
		List itemsList4 = new ArrayList();
		Items items4 = new Items();
		items4.setName("朱正磊4");
		itemsList4.add(items4);
		System.out.println(((Items)itemsList4.get(0)).getName());
	}*/

	/**
	 * @Desc 测试StringBuilder
	 * @param args
	 */
	/*public static void main(String[] args) {
		StringBuilder stringBuilder = new StringBuilder();//默认空字符串
		// TODO: 2017-07-08
		// TODO: 2017-07-08
		// FIXME: 2017-07-08
		// todo
		// fixme
		System.out.println(stringBuilder.toString() + "xx");
	}*/

	/**
	 * @Desc 测试jdk1.8新特性
	 * @param args
	 */
	/*public static void main(String[] args) {
		List<User> list = new ArrayList<>();
		User user1 = new User();
		user1.setUsername("张三");
		user1.setSex("1");
		User user2 = new User();
		user2.setUsername("李四");
		user2.setSex("0");
		User user3 = new User();
		user3.setUsername("王五");
		user3.setSex("1");
		list.add(user1);
		list.add(user2);
		list.add(user3);
		for(User user : list){
			if(user.getUsername().equals("张三")){
				System.out.println(user.getSex());
			}
		}

		list.stream()
				.filter(user -> user.getUsername().equals("张三"))
				//forEach()方法里面只有一行代码并且没有注释才可以简写去掉大括号。
				.forEach(user -> {
			System.out.println(user.getSex());
		});

		list.stream()
				.filter(user -> user.getUsername().equals("张三"))
				.forEach(user -> System.out.println(user.getSex()));

		//filter()方法和forEach()方法里面实例化对象的引用可以相同也可以不相同。
		list.stream()
				.filter(user -> user.getUsername().equals("张三"))
				.forEach(user4 -> System.out.println(user4.getSex()));

	}*/

	/**
	 * @Desc 测试jdk1.8新特性
	 * @param args
	 */
	/*public static void main(String[] args) {
		List<User> list = new ArrayList<>();
		User user1 = new User();
		user1.setUsername("张三");
		user1.setSex("1");
		User user2 = new User();
		user2.setUsername("李四");
		user2.setSex("0");
		User user3 = new User();
		user3.setUsername("王五");
		user3.setSex("1");
		list.add(user1);
		list.add(user2);
		list.add(user3);
		list.forEach(System.out::println);
	}*/

	/**
	 * @Desc 测试jdk1.8新特性
	 * @param args
	 */
	/*public static void main(String[] args) {
		List<String> stringCollection = new ArrayList<>();
		stringCollection.add("ddd2");
		stringCollection.add("aaa2");
		stringCollection.add("bbb1");
		stringCollection.add("aaa1");
		stringCollection.add("bbb3");
		stringCollection.add("ccc");
		stringCollection.add("bbb2");
		stringCollection.add("ddd1");
		long a = stringCollection.stream()
				.filter(s -> s.startsWith("a"))
				.count();
		System.out.println(a);
	}*/

	/**
	 * 说明：java.util.Objects是jdk1.7提供的工具类
	 * @Desc 测试基本数据类型==
	 * @param args
	 */
	/*public static void main(String[] args) {
		Integer a = 20;
		Integer b = 20;
		System.out.println(a == b);//true
		System.out.println(Objects.equals(a, b));//true
		Integer c = 200;
		Integer d = 200;
		System.out.println(c == d);//false
		System.out.println(Objects.equals(c, d));//true
		Integer e = 300;
		Integer f = 300;
		System.out.println(e == f);//false
		System.out.println(Objects.equals(e, f));//true
	}*/

	/**
	 * @Desc 测试jdk1.8新特性
	 * @param args
	 */
	/*public static void main(String[] args) {
		List<User> list = new ArrayList<>();
		User user1 = new User();
		user1.setUsername("张三");
		user1.setSex("1");
		User user2 = new User();
		user2.setUsername("李四");
		user2.setSex("0");
		User user3 = new User();
		user3.setUsername("王五");
		user3.setSex("1");
		list.add(user1);
		list.add(user2);
		list.add(user3);

		List<User> newList = new ArrayList<>();

		for(User user : list){
			System.out.println(user.getUsername());
		}

		/////1
		list.forEach(user -> user.getUsername());

		list.forEach(User::getUsername);
		/////

		/////2
		list.forEach(user -> {newList.add(user);});

		list.forEach(user -> newList.add(user));

		list.forEach(newList::add);
		/////

		/////3
		for(User user : list){
			System.out.println(user);
		}

		list.forEach(user -> {System.out.println(user);});

		list.forEach(user -> System.out.println(user));

		list.forEach(System.out::println);
		/////

		/////4
		list.stream()
				.filter(user -> user.getUsername().equals("王五"))
				.forEach(user -> System.out.println(user.getUsername()));
		/////

	}*/

	/**
	 * @Desc 测试jdk1.8新特性
	 * @param args
	 */
	/*public static void main(String[] args) {
		List<String> stringCollection = new ArrayList<>();
		stringCollection.add("1");
		stringCollection.add("2");
		stringCollection.add("3");
		stringCollection.add("4");
		stringCollection.add("5");
		stringCollection.add("6");
		stringCollection.add("7");
		stringCollection.add("8");
		stringCollection.stream()
				//.map(integer -> new Integer(integer))
				.map(Integer::new)
				//.forEach(i -> System.out.println(i));
				//.forEach(System.out::println);
				.forEach(i -> System.out.println(i.getClass()));
	}*/

	/**
	 * @Desc 测试==和equals
	 * @param args
	 */
	/*public static void main(String[] args) {
		byte b1 = 12;
		byte b2 = 12;
		boolean bool1 = b1 == b2;
		System.out.println(bool1);//true

		short s1 = 12;
		short s2 = 12;
		boolean bool2 = s1 == s2;
		System.out.println(bool2);//true

		int i1 = 12;
		int i2 = 12;
		boolean bool3 = i1 == i2;
		System.out.println(bool3);//true

		long l1 = 12;
		long l2 = 12;
		boolean bool4 = l1 == l2;
		System.out.println(bool4);//true
	}*/

	/**
	 * @Desc 测试==和equals
	 * @param args
	 */
	/*public static void main(String[] args) {
		float f1 = 97f;
		float f2 = 97F;
		boolean bool1 = f1 == f2;
		System.out.println(bool1);//true

		double d1 = 97d;
		double d2 = 97D;
		boolean bool2 = d1 == d2;
		System.out.println(bool2);//true
	}*/

	/**
	 * @Desc 测试==和equals
	 * @param args
	 */
	/*public static void main(String[] args) {
		char c1 = 97;
		char c2 = 97;
		boolean bool1 = c1 == c2;
		System.out.println(c1 + " " + c2);//a a
		System.out.println(bool1);//true

		char c3 = 'a';
		char c4 = 'a';
		boolean bool2 = c3 == c4;
		System.out.println(c3 + " " + c4);//a a
		System.out.println(bool2);//true
	}*/

	/**
	 * @Desc 测试==和equals
	 * @param args
	 */
	/*public static void main(String[] args) {
		boolean b1 = true;
		boolean b2 = true;
		boolean bool = b1 == b2;
		System.out.println(bool);//true
	}*/

	/**
	 * @Desc 测试==和equals
	 * @param args
	 */
	/*public static void main(String[] args) {
		Float f1 = 97F;
		Float f2 = 97F;
		boolean bool1 = f1 == f2;
		boolean bool2 = f1.equals(f2);
		System.out.println(bool1);//false
		System.out.println(bool2);//true

		Double d1 = 97D;
		Double d2 = 97D;
		boolean bool3 = d1 == d2;
		boolean bool4 = d1.equals(d2);
		System.out.println(bool3);//false
		System.out.println(bool4);//true
	}*/

	/**
	 * @Desc 测试==和equals
	 * @param args
	 */
	/*public static void main(String[] args) {
		Integer i1 = 97;
		Integer i2 = 97;
		boolean bool1 = i1 == i2;
		boolean bool2 = i1.equals(i2);
		System.out.println(bool1);//true
		System.out.println(bool2);//true

		Short s1 = 97;
		Short s2 = 97;
		boolean bool3 = s1 == s2;
		boolean bool4 = s1.equals(s2);
		System.out.println(bool3);//true
		System.out.println(bool4);//true

		Long l1 = 97L;
		Long l2 = 97L;
		boolean bool5 = l1 == l2;
		boolean bool6 = l1.equals(l2);
		System.out.println(bool5);//true
		System.out.println(bool6);//true

		Byte b1 = 50;
		Byte b2 = 50;
		boolean bool7 = b1 == b2;
		boolean bool8 = b1.equals(b2);
		System.out.println(bool7);//true
		System.out.println(bool8);//true
		System.out.println(b1 + " " + b2);//50 50
	}*/

	/**
	 * @Desc 测试==和equals
	 * @param args
	 */
	/*public static void main(String[] args) {
		Character c1 = 'a';
		Character c2 = 'a';
		boolean bool1 = c1 == c2;
		boolean bool2 = c1.equals(c2);
		System.out.println(bool1);//true
		System.out.println(bool2);//true
		System.out.println(c1 + " " + c2);//a a

		Character c3 = 97;
		Character c4 = 97;
		boolean bool3 = c3 == c4;
		boolean bool4 = c3.equals(c4);
		System.out.println(bool3);//true
		System.out.println(bool4);//true
		System.out.println(c3 + " " + c4);//a a
	}*/

	/**
	 * @Desc 测试==和equals
	 * @param args
	 */
	/*public static void main(String[] args) {
		Boolean b1 = true;
		Boolean b2 = true;
		boolean bool1 = b1 == b2;
		boolean bool2 = b1.equals(b2);
		System.out.println(bool1);//true
		System.out.println(bool2);//true
	}*/

	/**
	 * @Desc 测试==和equals
	 * @param args
	 */
	/*public static void main(String[] args) {
		String s1 = "abc";
		String s2 = "abc";
		boolean bool1 = s1 == s2;
		boolean bool2 = s1.equals(s2);
		boolean bool3 = Objects.equals(s1, s2);
		boolean bool4 = StringUtils.equals(s1, s2);
		System.out.println(bool1);//true
		System.out.println(bool2);//true
		System.out.println(bool3);//true
		System.out.println(bool4);//true
	}*/

	/**
	 * @Desc 测试map打印输出
	 * @param args
	 */
	/*public static void main(String[] args) throws Exception {
		User user = new User();
		user.setUsername("张三");
		user.setSex("1");
		user.setId(1);
		user.setBirthday(new Date());
		user.setAddress("苏州");
		Map<String, Object> map = MapUtil.javaBean2Map(user);
		//{birthday=Sun Jul 30 19:05:09 CST 2017, address=苏州, sex=1, id=1, username=张三}
		System.out.println(map);
		//{id=1, username=张三, birthday=Sun Jul 30 19:05:09 CST 2017, sex=1, address=苏州}
		System.out.println(user);
	}*/

	/**
	 * @Desc 测试map字符串截取部分字符串
	 * @param args
 	*/
	/*public static void main(String[] args) throws Exception {
		String mapString = "{id=1, username=张三, birthday=Sun Jul 30 19:05:09 CST 2017, sex=1, address=苏州}";
		//{id=1, username=张三, birthday=Sun Jul 30 19:05:09 CST 2017, sex=1, address=苏州}
		System.out.println(mapString);
		//String的substring方法包含开始索引不包含结束索引。
		String subMapString = mapString.substring(1, mapString.length() - 1);
		//id=1, username=张三, birthday=Sun Jul 30 19:05:09 CST 2017, sex=1, address=苏州
		System.out.println(subMapString);
		String[] keyValueArray = subMapString.split(", ");
		//[id=1, username=张三, birthday=Sun Jul 30 19:05:09 CST 2017, sex=1, address=苏州]
		//打印数组的话需要先转成字符串，使用Arrays.toString方法。
		System.out.println(Arrays.toString(keyValueArray));

		Map<String, String> map = MapUtil.mapStringToMap(mapString);
		//{id=1, username=张三, birthday=Sun Jul 30 19:05:09 CST 2017, sex=1, address=苏州}
		System.out.println(map);
	}*/

	/**
	 * @Desc 测试==和equals
	 * @param args
	 */
	/*public static void main(String[] args) {
		User user1 = new User();
		user1.setId(1);

		User user2 = new User();
		user2.setId(1);

		User user3 = new User();
		user3.setId(2);

		User user4 = user1;

		System.out.println(user1.equals(user2));//true
		System.out.println(user1.equals(user3));//false

		//同一对象的不同引用
		System.out.println(user1.equals(user4));//true
	}*/

	/**
	 * @Desc 测试==和equals
	 * @param args
	 */
	/*public static void main(String[] args) {
		People people1 = new People();
		people1.setId("123");
		people1.setName("张三");

		People people2 = new People();
		people2.setId("123");
		people2.setName("张三");

		People people3 = new People();
		people3.setId("123");
		people3.setName("李四");

		People people4 = new People();
		people4.setId("234");
		people4.setName("李四");

		//People[id=123,name=张三,age=0,pay=0.0,valid=false,one= ,birthday=<null>,link=<null>,map=<null>,list=<null>,set=<null>]
		System.out.println(people1);

		System.out.println(people1.equals(people2));//true
		System.out.println(people1.equals(people3));//false
		System.out.println(people3.equals(people4));//false
	}*/

	/**
	 * @Desc
	 * @param args
	 */
	/*public static void main(String[] args) {
		User user = new User();
		user.setUsername("张三");
		user.setSex("1");
		user.setId(1);
		user.setBirthday(new Date());
		user.setAddress("苏州");
		//{birthday=Mon Jul 31 16:41:03 CST 2017, address=苏州, sex=1, id=1, username=张三}
		//{id=1, username=张三, birthday=Mon Jul 31 16:41:54 CST 2017, sex=1, address=苏州}
		System.out.println(user.toString());
	}*/

	/**
	 * @Desc 数组和集合
	 * @param args
	 */
	/*public static void main(String[] args) {
		String[] array = {"abc", "123", "k98j", "00jh"};
		List<String> stringList = Arrays.asList(array);
		System.out.println(Arrays.toString(array));
		System.out.println(stringList);
	}*/

	/**
	 * @Desc 测试创建多级目录
	 * @param args
	 */
	/*public static void main(String[] args) {
		File dir = new File("E:\\downloads");
		boolean flag =  dir.exists() || dir.mkdirs();
		System.out.println(flag);
	}*/

	/**
	 * @Desc 测试创建多级目录
	 * @param args
	 */
	/*public static void main(String[] args) {
		File dir = new File("E:\\downloads");
		boolean flag ;
		if(dir.exists()){
			flag = true;
		}else{
			flag = dir.mkdirs();
		}
		System.out.println(flag);
	}*/

	/**
	 * @Desc 测试创建多级目录
	 * @param args
	 */
	/*public static void main(String[] args) {
		File dir = new File("E:\\downloads");
		boolean flag ;
		if(!dir.exists()){
			flag = dir.mkdirs();
		}else{
			flag = true;
		}
		System.out.println(flag);
	}*/

	/**
	 * @Desc for循环需要注意的问题
	 * @param args
	 */
	/*public static void main(String[] args) {
		List<User> userList1 = new ArrayList<User>();
		User user1 = new User();
		user1.setId(1);
		User user2 = new User();
		user2.setId(2);
		User user3 = new User();
		user3.setId(3);
		userList1.add(user1);
		userList1.add(user2);
		userList1.add(user3);
		List<User> userList11 = new ArrayList<User>();
		User user11 ;
		if(!userList1.isEmpty()){
			for(User user : userList1){
				user11 = new User();
				user11.setId(user.getId());
				userList11.add(user11);
			}
		}
		//System.out.println(user11);
		System.out.println(userList11);
	}*/

	/**
	 * @Desc 测试JSONObject 和 JSONArray
	 * @param args
	 */
	/*public static void main(String[] args) {
		String jsonObjectString = "{'id':1,'name':'马云','birth':'1970-10-20 14:06:22','age':50,'isdead':false}";
		String jsonArrayString = "[{'id':2,'name':'马化腾','birth':'1971-10-29 14:06:22','age':45,'isdead':false},"
				+ "{'id':3,'name':'毛泽东','birth':'1893-12-26 14:06:22','age':83,'isdead':true}]";
		JSONObject jsonObject = JSONUtils.jsonObjectString2JsonObject(jsonObjectString);
		JSONArray jsonArray = JSONUtils.jsonArrayString2JsonArray(jsonArrayString);
		System.out.println(jsonObject.size());//输出5，这里的size指的是JSONObject中的key/value个数
		System.out.println(jsonArray.size());//输出2，这里的size指的是JSONArray中JSONObject的个数
	}*/

	/**
	 * @Desc 测试变量初始化
	 * @param args
	 */
	/*public static void main(String[] args) {
		List<User> userList = new ArrayList<>();
		User user1 = new User();
		user1.setId(1);
		userList.add(user1);
		User user2 = new User();
		user2.setId(2);
		userList.add(user2);
		for (User user : userList) {
			System.out.println(user.getId());
		}
	}*/

	/**
	 * @Desc 测试Arrays工具类
	 * @param args 参数
	 */
	/*public static void main(String[] args) {
		int[] data = {1, 2, 3, 4};
		System.out.println(Arrays.toString(data));//[1, 2, 3, 4]
		List<int[]> intArrayList = Arrays.asList(data);
		System.out.println(intArrayList.toString());//[[I@5b6f7412]
		System.out.println(intArrayList.size());//1
		//intArrayList.add(new int[]{5});
		//System.out.println(intArrayList.size());

		Integer[] data1 = {1, 2, 3, 4};
		System.out.println(Arrays.toString(data1));//[1, 2, 3, 4]
		List<Integer> integerArrayList = Arrays.asList(data1);
		System.out.println(integerArrayList.toString());//[1, 2, 3, 4]
		System.out.println(integerArrayList.size());//4
		//integerArrayList.add(5);
		//System.out.println(integerArrayList.size());

		String[] data2 = {"abc", "bcd", "cde", "def"};
		System.out.println(Arrays.toString(data2));//[abc, bcd, cde, def]
		List<String> stringList = Arrays.asList(data2);
		System.out.println(stringList.toString());//[abc, bcd, cde, def]
		System.out.println(stringList.size());//4
		//stringList.add("efg");
		//System.out.println(stringList.size());

		List abc = Arrays.asList("a", 1, true);
		//abc.add(2);
		System.out.println(abc.toString());//[a, 1, true]
	}*/

	/**
	 * @Desc 测试split方法
	 * @param args 参数
	 */
	/*public static void main(String[] args) {
		String str = "hello world nihao rambo";
		String[] result = str.split(" ", 3);
		System.out.println(result.length);
		System.out.println(Arrays.toString(result));
		for (String param : result) {
			System.out.println(param);
		}
	}*/

	/**
	 * @Desc 测试Map的put方法
	 * @param args 参数
	 */
	/*public static void main(String[] args) {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("name", "张三");
		map.put("name", "李四");
		map.put("name", "王五");
		System.out.println(map.get("name"));//王五
	}*/

	/**
	 * @Desc 测试for循环以及变量初始化
	 * @param args 参数
	 */
	/*public static void main(String[] args) {
		*//*for (int i = 0; i < 10000; ++i) {
			Object obj = new Object();
			System.out.println("obj= "+ obj);
		}*//*

		Object obj;
		for (int i = 0; i < 10000; ++i) {
			obj = new Object();
			System.out.println("obj= "+ obj);
		}
	}*/

	/**
	 * @Desc 测试lambda
 	 * @param args 参数
	 */
	/*public static void main(String[] args) {
		List<PartAssembly> partAssemblyList = v.stream()
				.filter(it->lineNums.contains(it.getLineNum())).collect(Collectors.toList());
	}*/

	/**
	 * @Desc 测试lambda
	 * @param args 参数
	 */
	/*public static void main(String[] args) {
		List<User> v = new ArrayList<>();
		User user1 = new User();
		user1.setSex("男");
		User user2 = new User();
		user2.setSex("男");
		User user3 = new User();
		user3.setSex("女");
		v.add(user1);
		v.add(user2);
		v.add(user3);
		List<String> sexs = new ArrayList<>();
		sexs.add("男");
		sexs.add("不男不女");
		List<User> userList = v.stream()
				.filter(user->sexs.contains(user.getSex())).collect(Collectors.toList());
		//[{id=null, username=null, birthday=null, sex=男, address=null}, {id=null, username=null, birthday=null, sex=男, address=null}]
		System.out.println(userList);
	}*/

	/**
	 * @Desc 测试lambda
	 * @param args 参数
	 */
	/*public static void main(String[] args) {
		List<User> userList = new ArrayList<>();
		User user1 = new User();
		user1.setSex("男");
		User user2 = new User();
		user2.setSex("男");
		User user3 = new User();
		user3.setSex("女");
		userList.add(user1);
		userList.add(user2);
		userList.add(user3);
		List<String> stringList = new ArrayList<>();
		for (User user : userList) {
			stringList.add(user.getSex());
		}
		System.out.println(stringList);
	}*/

	/**
	 * @Desc 测试lambda
	 * @param args 参数
	 */
	/*public static void main(String[] args) {
		List<User> userList = new ArrayList<>();
		User user1 = new User();
		user1.setSex("男");
		User user2 = new User();
		user2.setSex("男");
		User user3 = new User();
		user3.setSex("女");
		userList.add(user1);
		userList.add(user2);
		userList.add(user3);
		List<String> stringList = userList.stream().map(User::getSex).collect(Collectors.toList());
		System.out.println(stringList);
	}*/

	/**
	 * @Desc 测试Map的用法
	 * @param args 参数
	 */
	/*public static void main(String[] args) {
		List<Map<String, Object>> mapList = new ArrayList<>();
		Map<String, Object> map1 = new LinkedHashMap<>();
		Map<String, Object> map2 = new LinkedHashMap<>();
		Map<String, Object> map3 = new LinkedHashMap<>();
		map1.put("id", 1);
		map1.put("name", "张三");
		map1.put("city", "南京");
		mapList.add(map1);
		map2.put("id", 2);
		map2.put("name", "张三");
		map2.put("birthday", "北京");
		mapList.add(map2);
		map3.put("id", 3);
		map3.put("name", "张三");
		map3.put("birthday", "上海");
		mapList.add(map3);
		List<Object> objectList = new ArrayList<>();
		for (Map<String, Object> map : mapList) {
			Collection<Object> values = map.values();
			Iterator<Object> iterator = values.iterator();
			List<Object> objects = ListUtil.iteratorToList(iterator);
			//[1, 2, 3]
			objectList.add(objects.get(0));
		}
		for (Map<String, Object> map : mapList) {
			Set<String> set = map.keySet();
			Iterator<String> iterator = set.iterator();
			List<String> stringList = ListUtil.iteratorToList(iterator);
			//[id, id, id]
			objectList.add(stringList.get(0));
		}
		for (Map<String, Object> map : mapList) {
			Set<Map.Entry<String, Object>> entries = map.entrySet();
			Iterator<Map.Entry<String, Object>> iterator = entries.iterator();
			List<Map.Entry<String, Object>> entryList = ListUtil.iteratorToList(iterator);
			Map.Entry<String, Object> entry = entryList.get(0);
			String key = entry.getKey();
			Object value = entry.getValue();
			String keyAndValue = key + "=" + value;
			//[id=1, id=2, id=3]
			objectList.add(keyAndValue);
		}
		System.out.println(objectList);
	}*/

	/**
	 * @Desc 测试Map的用法
	 * @param args 参数
	 */
	/*public static void main(String[] args) {
		List<Map<String, Object>> mapList = new ArrayList<>();
		Map<String, Object> map1 = new LinkedHashMap<>();
		Map<String, Object> map2 = new LinkedHashMap<>();
		Map<String, Object> map3 = new LinkedHashMap<>();
		map1.put("id", 1);
		map1.put("name", "张三");
		map1.put("city", "南京");
		mapList.add(map1);
		map2.put("id", 2);
		map2.put("name", "张三");
		map2.put("birthday", "北京");
		mapList.add(map2);
		map3.put("id", 3);
		map3.put("name", "张三");
		map3.put("birthday", "上海");
		mapList.add(map3);
		List<Object> objectList = new ArrayList<>();
		mapList.forEach(map -> {
			Collection<Object> values = map.values();
			Iterator<Object> iterator = values.iterator();
			List<Object> objects = ListUtil.iteratorToList(iterator);
			//[1, 2, 3]
			objectList.add(objects.get(0));
		});
		mapList.forEach(map -> {
			Set<String> set = map.keySet();
			Iterator<String> iterator = set.iterator();
			List<String> stringList = ListUtil.iteratorToList(iterator);
			//[id, id, id]
			objectList.add(stringList.get(0));
		});
		mapList.forEach(map -> {
			Set<Map.Entry<String, Object>> entries = map.entrySet();
			Iterator<Map.Entry<String, Object>> iterator = entries.iterator();
			List<Map.Entry<String, Object>> entryList = ListUtil.iteratorToList(iterator);
			Map.Entry<String, Object> entry = entryList.get(0);
			String key = entry.getKey();
			Object value = entry.getValue();
			String keyAndValue = key + "=" + value;
			//[id=1, id=2, id=3]
			objectList.add(keyAndValue);
		});
		System.out.println(objectList);
	}*/

	/**
	 * @Desc 测试jdk1.8新特性
	 * @param args
	 */
	/*public static void main(String[] args) {
		List<User> list = new ArrayList<>();
		User user1 = new User();
		user1.setUsername("张三");
		user1.setSex("1");
		User user2 = new User();
		user2.setUsername("李四");
		user2.setSex("0");
		User user3 = new User();
		user3.setUsername("王五");
		user3.setSex("1");
		list.add(user1);
		list.add(user2);
		list.add(user3);

		for(User user : list){
			System.out.println(user.getUsername());
		}
		list.forEach(user -> System.out.println(user.getUsername()));

		for(User user : list){
			user.getUsername();
		}
		list.forEach(user -> user.getUsername());
		list.forEach(User::getUsername);
	}*/

	/**
	 * @Desc 测试i++和++i
	 * @param args 参数
	 */
	/*public static void main(String[] args) {
		int d = 25;
		int v = +(d++);//小括号前面的+表示正负，括号里面的++表示先把d赋值给v然后再自身加1；
		System.out.println(v);//25
	}*/

	/**
	 * @Desc 测试i++和++i
	 * @param args 参数
	 */
	/*public static void main(String[] args) {
		int d = 25;
		int i = d++;
		System.out.println(i);//25
		int v = +(d++);
		System.out.println(v);//26
	}*/
	
	/**
	 * @description 测试Map的size()方法
	 * @param args
	 */
	/*public static void main(String[] args) {
		Map<String, Object> map = new HashMap<>();
	    map.put("apple", "新鲜的苹果");//向列表中添加数据
	    map.put("computer", "配置优良的计算机");//向列表中添加数据
	    map.put("book", "堆积成山的图书");//向列表中添加数据
	    System.out.println("Map集合大小为：" + map.size());//Map集合大小为：3
	}*/
	
	/**
	 * @description 测试do while
	 * @param args
	 */
	/*public static void main(String[] args) {
		int a = 1;
		int b = 0;
		do {
			if (a % 2 == 0) {//余数为0
				b += a;
			}
			a ++;
		} while (a <= 10);
		
		System.out.println(b);//打印输出30
	}*/
	
	/**
	 * @description 测试while
	 * @param args
	 */
	/*public static void main(String[] args) {
		int a = 1;
		int b = 0;
		while (a <= 10) {
			b += a;
			a ++;
		}
		System.out.println(b);//打印输出55
	}*/
	
	/**
	 * @description 使用for循环代替while循环
	 * @param args
	 */
	/*public static void main(String[] args) {
		int b = 0;
		for (int a = 1; a <= 10; a++) {
			if (a % 2 == 0) {
				b += a;
			}
		}
		System.out.println(b);//打印输出30
	}*/
	
	/**
	 * @description 测试iterator
	 * @param args
	 */
	/*public static void main(String[] args) {
		List<Object> list = new ArrayList<>();
		list.add("123");
		list.add("abc");
		list.add(100);
		for (Iterator<Object> iterator = list.iterator(); iterator.hasNext();) {
			Object ite = iterator.next();
			System.out.println(ite);
		}
	}*/
	
	/**
	 * @description 测试iterator
	 * @param args
	 */
	/*public static void main(String[] args) {
		List<Object> list = new ArrayList<>();
		list.add("123");
		list.add("abc");
		list.add(100);
		Iterator<Object> iterator = list.iterator();
		while (iterator.hasNext()) {
			Object ite = iterator.next();
			System.out.println(ite);
		}
	}*/
	
	/**
	 * @description for和while的区分
	 * @param args
	 */
	/*public static void main(String[] args) {
		//1、for循环
		int m = 0;
		for (int i = 0; i < 10; i++) {
			m += i;
		}
		System.out.println(m);//打印输出45
		
		//2、while循环
		int a = 0;
		int n = 0;
		while (a < 10) {
			n += a;
			a ++;
		}
		System.out.println(n);//打印输出45
	}*/
	
	/**
	 * @description 计算 2 + 4 + 6 + ... + 100的值
	 * @param args
	 */
	/*public static void main(String[] args) {
		int a = 1;
		int sum = 0;
		do {
			if (a % 2 == 0) {
				sum += a;
			}
			a ++;
		} while (a <= 100);
		System.out.println(sum);
	}*/
	
	/**
	 * @description 
	 * @param args
	 */
	/*public static void main(String[] args) {
		int sum1 = sum(100);
		int sum2 = sum(1000);
		int sum3 = sumEven(100);
		int sum4 = sumEven(1000);
		System.out.println(sum1);//打印输出2550
		System.out.println(sum2);//打印输出250500
		System.out.println(sum3);//打印输出2550
		System.out.println(sum4);//打印输出250500
	}
	
	//计算 2 + 4 + 6 + 8 + ...
	private static int sum(int number) {
		int sum = 0;
		for (int i = 1; i <= number / 2; i++) {
			sum += i * 2;
		}
		return sum;
	}
	
	//计算 2 + 4 + 6 + 8 + ...
	private static int sumEven(int number) {
		int sum = 0;
		int x = 2;
		while (x <= number) {
			sum += x;
			x += 2;
		}
		return sum;
	}*/
	
	/**
	 * @description 
	 * @param args
	 */
	/*public static void main(String[] args) {
		int sum1 = sumOdd1(99);
		int sum2 = sumOdd2(99);
		System.out.println(sum1);
		System.out.println(sum2);
	}
	
	//计算1 + 3 + 5 + 7 + ...
	private static int sumOdd1(int number) {
		int sum = 0;
		int x = 1;
		while (x <= number) {
			sum += x;
			x += 2;
		}
		return sum;
	}
	
	//计算1 + 3 + 5 + 7 + ...
	private static int sumOdd2(int number) {
		int sum = 0;
		for (int i = 1; i <= number; i++) {
			if (i % 2 != 0) {
				sum += i;
			}
		}
		return sum;
	}*/
	
	/*@SuppressWarnings("unused")
	private String testMethod(String name) {
		return name + "测试利用反射机制调用别的类的私有方法";
	}*/
	
	/**
	 * @description TODO
	 * @param args
	 */
	/*public static void main(String[] args) {
		String str = ArrayUtil.strArr2String("start", "end");
		System.out.println(str);
		str = ArrayUtil.strArr2String("start", "end", "123", "abc");
		System.out.println(str);
	}*/
	
	/*public static void main(String[] args) {
		Map<String, String> hashMap = new HashMap<String, String>();
		hashMap.put("a", "a");
		hashMap.put("b", "b");
		hashMap.put("c", "c");
		String signChain_hash = MapUtil.getSignChain(hashMap);
		System.out.println(signChain_hash);//b=b&c=c&a=a
		
		Map<String, String> treeMap = new TreeMap<String, String>();
		treeMap.put("a", "a");
		treeMap.put("c", "c");
		treeMap.put("b", "b");
		String signChain_tree = MapUtil.getSignChain(treeMap);
		System.out.println(signChain_tree);//a=a&b=b&c=c
	}*/
	
	/**
	 * @description 测试读取配置文件里面的键值对
	 * @param args
	 */
	/*public static void main(String[] args) {
		ResourceUtil resource = new ResourceUtil("resource/resource");
		String value_1 = resource.getValue("key_1");
		System.out.println(value_1 + ";");//那吾克热;
		String value_2 = resource.getValue("key_2");
		System.out.println(value_2 + ";");//艾热;
		String value_3 = resource.getValue("key_3");
		System.out.println(value_3 + ";");//满舒克;
		String value_4 = resource.getValue("key_4");
		System.out.println(value_4 + ";");//李佳隆 ;
		String value_5 = resource.getValue("key_5");
		System.out.println(value_5 + ";");//陈梓童  ;
		String value_6 = resource.getValue("key_6");
		System.out.println(value_6 + ";");//6 ;
		String value_7 = resource.getValue("key_7");
		System.out.println(value_7 + ";");//seven  ;
		
		String value_8 = resource.getValue("key_8");//"null"
		if ("null".equals(value_8)) {
			System.out.println(value_8 + ";");//null;
		}
		
		//【读取配置文件出错，请确保您要查找的key_9在该配置文件里面存在！】
		String value_9 = resource.getValue("key_9");//null
		if (null == value_9) {
			System.out.println(value_9 + ";");//null;
		}
		
		//【空指针异常，请确保key不为null】
		String value_10 = resource.getValue(null);//null
		if (null == value_10) {
			System.out.println(value_10 + ";");//null;
		}
	}*/
	
	/**
	 * @description 测试分转元和元转分
	 * @param args
	 */
	public static void main(String[] args) {
		String yuan = MathUtil.fenToYuan("1234.00");
		System.out.println(yuan);//12.34
		String fen = MathUtil.yuanToFen(yuan);
		System.out.println(fen);//1234.00
	}

}
